package day14;

import java.util.concurrent.ArrayBlockingQueue;

public class homework003 extends Thread {
    private ArrayBlockingQueue<Integer> qu;

    public homework003(ArrayBlockingQueue<Integer> qu) {
        this.qu = qu;
    }

    @Override
    public void run() {
        while (true) {
            try {
                if (qu.isEmpty()) {
                    break;
                } else {
                    int num = qu.take();
                    if (num % 3 == 0 && num % 5 == 0) {
                        System.out.print("fizzbizz,");
                    } else if (num % 3 == 0) {
                        System.out.print("fizz,");
                    } else if (num % 5 == 0) {
                        System.out.print("bizz,");
                    } else {
                        System.out.print(num + ",");
                    }
                    try {
                        sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
